package com.sanctuary.tools;

import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sanctuary.interfaces.BaseConstants;
import com.sanctuary.interfaces.IocEngine;
import com.sanctuary.interfaces.ObjectSerializer;

public abstract class BaseTool {
	private static final Log 					LOG = LogFactory.getLog(BaseTool.class);
	public static IocEngine 					IOC_ENGINE;
	public static CompositeConfiguration		BASE_CONFIG;
	public static ConfigurationBean				CONFIG_BEAN;
	public static ObjectSerializer				OBJECT_SERIALIZER;
	
	static {
		try {
			IOC_ENGINE = (IocEngine) Class.forName(BaseConstants.IOC_CONTAINER_CLASS).newInstance();
			LOG.debug("IOC ENGINE: " + IOC_ENGINE.getClass().getName() + " instantiated");
			BASE_CONFIG = (CompositeConfiguration) IOC_ENGINE.getBean("appProperties");
			CONFIG_BEAN = (ConfigurationBean) IOC_ENGINE.getBean("baseConfig");
			OBJECT_SERIALIZER = (ObjectSerializer) IOC_ENGINE.getBean("objectSerializer");
		} catch (Exception ex) {
			LOG.fatal("This isn't good",ex);
		}
	}
}
